
var isTouch = false;
var isMove =false;
var originX;
var originY;
/**
 * 地图手势
 */
$("html").bind({
	//触摸手势
    'touchstart mousedown' : function(e){
        isMove = true;
        isTouch = true;
        originX = e.touches[0].clientX;
        originY = e.pageY;
//        originX = e.originalEvent.targetTouches[0].clientX;
//        originY = e.originalEvent.targetTouches[0].clientY;
        
        console.log('触摸手势 isMove:'+originX+'  isTouch:'+originY);
    },
    //拖动手势
    'touchmove mousemove' : function(e){
    	var a = e;
    	//isMove = true;
    	//图片右边距离屏幕左边的距离
        var right = $("#map").offset().left + $("#map").width();
        //图片左边距离屏幕左边的距离
        var left = $("#map").offset().left;
        //图片下边边距离屏幕上边的距离
        var bottom = $("#map").offset().top + $("#map").height();
        //图片上边距离屏幕上边的距离
        var top = $("#map").offset().top;
        //console.log("right:"+right+"  left:"+left+"  bottom:"+bottom+"  top:" + top);
        if(right < 10 || -left > $("#map").width() || bottom < 0 || -top > $("#map").height()){
        	return;
        }
        if(isMove == true){
        	var offX = e.pageX - originX;
        	var offY = e.pageY - originY;
        	console.log(offX);
        	$("#map").css("left",$("#map").offset().left+offX)
        	//.css("top",$("#map").offset().top+offY); 
        	originX = e.pageX;
        	originY = e.pageY;
        	console.log('拖动手势isMove:'+isMove+'  isTouch:'+isTouch);
        }
        
    },
    //松开手势
    'touchend touchcancel mouseup' : function(e){
    	//console.log('松开手势isMove:'+isMove+'  isTouch:'+isTouch);
        isMove = false;
        if(isTouch == true){
        	var x =   e.pageX -$("#map").offset().left;
        	var y = e.pageY - $("#map").offset().top  ;
        	console.log('点击图片位置x: '+x + "   y:"+ y);
        	//$("#logger p").html('点击图片位置x: '+x + "   y:"+ y);
        	console.log('松开手势isMove:'+isMove+'  isTouch:'+isTouch);
        }
    }
});




